﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title></title>
    <script type="text/javascript" src="../../../Content/highlighter/scripts/shCore.js"></script>
    <script type="text/javascript" src="../../../Content/highlighter/scripts/shBrushJScript.js"></script>
    <script type="text/javascript" src="../../../Content/highlighter/scripts/shBrushCSharp.js"></script>
    <script type="text/javascript" src="../../../Content/highlighter/scripts/shBrushXml.js"></script>
    <link type="text/css" rel="stylesheet" href="../../../Content/highlighter/styles/shCore.css" />
    <link type="text/css" rel="stylesheet" href="../../../Content/highlighter/styles/shCoreEclipse.css" />
    <script type="text/javascript">SyntaxHighlighter.all();</script>
</head>
<body>
    <h3>使用自定义类获取参数</h3>
    定义如下类型作为接收请求参数的实体类：<br />
    <pre class="brush:csharp;">
    namespace NFinalWeb3.Controllers
    {    
        public class User
        {
            public string UserName;
            public int UeserAge;
            public DateTime Birthday;
        }
    }
    </pre>
    1.使用GetModel方法自动获取参数
    <pre class="brush:csharp;">
    using System;
    using System.Collections.Generic;
    using System.Text;
    using NFinal;

    namespace NFinalWeb3.Controllers
    {
        public class Index1Controller : BaseController
        {
            public ActionResult Index()
            {
                User user=this.GetModel&lt;User>();
                return null;
            }
        }
    }
    </pre>
    2.使用参数自动获取
    <pre class="brush:csharp;">
    using System;
    using System.Collections.Generic;
    using System.Text;
    using NFinal;

    namespace NFinalWeb3.Controllers
    {
        public class Index1Controller : BaseController
        {
            public ActionResult Index(User user)
            {
                var myUser=user;
                return null;
            }
        }
    }
    </pre>
</body>
</html>